package base.Day04.Exercies;


public class Exercise
{
    public static void main(String[] args)
    {
        Exercise exercise = new Exercise();
//        exercise.exercise1();
//        exercise.exercise2();
        exercise.exercise3();
//        exercise.exercise4();
    }

    public void exercise1()
    {
        //输出1900到2023年之间所有的闰年(每够10个年份，换一行)
        int count = 0;
        for(int year = 1900; year <= 2023; year++)
        {
            if(year % 4 == 0 && year % 100 != 0)
            {
                System.out.print(year+" ");
                count++;
                if(count == 10)
                {
                    count = 0;
                    System.out.println();
                }
            }
        }


    }

    public void exercise2()
    {
        //利用for循环计算：求数字1到100之内，所有偶数的和，并输出
        int sum = 0;
        for (int i = 0 ; i < 100 ; i++)
        {
            if(i % 2 == 0)
            {
                sum += i;
            }

        }
        System.out.println(sum);
    }
    public void exercise3()
    {
        // 利用for循环计算：求8的阶乘，并输出
        int num = 1;
        int eight = 8;
        while (true)
        {
            num *= eight--;
            if(eight == 1)
                break;
        }
        System.out.println("8的阶乘为"+num);
    }
    public void exercise4()
    {
        for (int i = 1 ; i <= 11; i+=2)
        {
            for (int j = 1; j <=i ; j++)
            {
                System.out.print("*");
            }
            System.out.println();
        }
    }


}
